package com.situ.mall.controller.back;

import org.apache.taglibs.standard.extra.spath.Step;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.mall.common.ServerResponse;
import com.situ.mall.entity.Shipping;
import com.situ.mall.service.IShippingService;

@Controller
@RequestMapping(value="/shipping")
public class ShippingController {
	@Autowired
	private IShippingService shippingService;
	
	//网页点击页面展示
	@RequestMapping(value="/getShippingPage")
	public String getShippingPage() {
		return "shipping/shipping_list";
	}
	
	//分页
	@RequestMapping(value="/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer page,Integer limit,Shipping shipping) {
		ServerResponse serverResponse = shippingService.pageList(page,limit,shipping);
		System.out.println(serverResponse);
		return serverResponse;
	}
	
	//Id删除
	@RequestMapping(value="/deleteById")
	@ResponseBody
	public ServerResponse deleteById(Integer id) {
		return shippingService.deleteById(id);
	}
	
	//批量删除
	@RequestMapping(value="/deleteAll")
	@ResponseBody
	public ServerResponse deleteAll(String ids) {
		return shippingService.deleteAll(ids);
	}
	
	//添加页面
	@RequestMapping(value="/getAddPage")
	public String getAddPage() {
		return "shipping/shipping_add";
	}
	
	//添加功能
	@RequestMapping(value="/insert")
	@ResponseBody
	public ServerResponse insert(Shipping shipping) {
		return shippingService.insert(shipping);
	}
	
	//修改页面
	@RequestMapping(value="/getToUpdatePage")
	public String getToUpdatePage(Integer id,Model model) {
		Shipping shipping = shippingService.toUpdate(id);
		model.addAttribute("shipping",shipping);
		return "shipping/shipping_update";
	}
	
	//修改功能
	@RequestMapping(value="/update")
	@ResponseBody
	public ServerResponse update(Shipping shipping) {
		System.out.println(shipping);
		return shippingService.update(shipping);
	}
}
